package cn.stylefeng.guns.modular.business.service.impl;

import cn.stylefeng.guns.modular.business.entity.MessageNotice;
import cn.stylefeng.guns.modular.business.mapper.MessageNoticeMapper;
import cn.stylefeng.guns.modular.business.service.MessageNoticeService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class MessageNoticeServiceImpl extends ServiceImpl<MessageNoticeMapper, MessageNotice> implements MessageNoticeService {

    @Autowired
    MessageNoticeMapper messageNoticeMapper;

    @Override
    public List<MessageNotice> list(Page page, String condition, String type) {
        return messageNoticeMapper.list(page, condition, type);
    }

    /**
     * 新增消息
     *
     * @param title
     * @param content
     * @param type
     * @return
     */
    @Override
    public boolean add(String title, String content, String type) {
        MessageNotice messageNotice=new MessageNotice();
        messageNotice.setTitle(title);
        messageNotice.setContent(content);
        messageNotice.setType(type);
        messageNotice.setCreateTime(new Date());
        messageNotice.setUpdateTime(new Date());
        return this.save(messageNotice);
    }
}
